home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / chkdv.arc / CHECKDV.ASM next >
Assembly Source File  |  1988-09-30  |  20KB  |  446 lines

  1. comment ~
  2. /*@H************************ < Mylibrary       > ****************************
  3. *                                                                           *
  4. *   CHECKDV  : checkdv.asm API routines to check for Desqview               *
  5. *                                                                           *
  6. *   Author   : Donald J. Gloistein                                          *
  7. *                                                                           *
  8. *   Program, Source, Documentation (c) 1987, all rights reserved.           *
  9. *                                                                           *
  10. *   Compiled code may be used in your library, and linked to your programs  *
  11. *   BUT, the source code nor a library based on the compiled modules may be *
  12. *   commercially distributed.                                               *
  13. *   This is not shareware, no donation is expected. But I do retain rights  *
  14. *   to the source.                                                          *
  15. *                                                                           *
  16. *   See manual for license and information to general public.               *
  17. *   Any code derived from other sources will be noted in comments.          *
  18. *                                                                           *
  19. *                                                                           *
  20. *---------------------------  Module Description  --------------------------*
  21. *  This code was based closely on the samples provided by Quarterdeck for   *
  22. *  their version 2 Desqview (tm).  Modifications made to use C calling      *
  23. *  conventions and initialize global variables for the program to use.      *
  24. *                                                                           *
  25. *                                                                           *
  26. *                                                                           *
  27. *   Function names:                                                         *
  28. *     int dv_get_dv_version(void)                                           *
  29. *     unsigned int dv_get_video_buffer(unsigned int)                        *
  30. *     void dv_pause(void)                                                   *
  31. *     void dv_begin_critical(void)                                          *
  32. *     void dv_end_critical(void)                                            *
  33. *   Globals that can be used:                                               *
  34. *     int in_dv               True if dv present                            *
  35. *     unsigned dv_vid_seg     segment address of buffer                     *
  36. *     unsigned dv_vid_off     offset of buffer (usually 0)                  *
  37. *     int dv_maj_version      major version number if in_dv                 *
  38. *     int dv_min_version      minor version number if in_dv                 *
  39. *                                                                           *
  40. *                                                                           *
  41. *--------------------------- Implementation Notes --------------------------*
  42. *                                                                           *
  43. *   compiled with :                                                         *
  44. *   compiled by   : MASM v.5.0                                              *
  45. *                                                                           *
  46. *   linked with   : MYLIB.LIB                                               *
  47. *   linked by     : MICROSOFT LINK                                          *
  48. *                                                                           *
  49. *   As written, this module is set for the C calling conventions of         *
  50. *   Microsoft C version 5.0, it takes advantage of none of the upgraded     *
  51. *   options of Masm 5.0, especially the memory model feature. This may not  *
  52. *   be true in the future.                                                  *
  53. *   It is designed to be called with model defined or small memory is       *
  54. *   assumed.  This is done on the command line as follows:                  *
  55. *         masm /MX /Dsmall filename ;      gives small model                *
  56. *         mams /MX /Dmedium filename ;     gives medium model               *
  57. *   While it is not necessary to define small, it is included to help in    *
  58. *   batch files.                                                            *
  59. *                                                                           *
  60. *   The dv_get_video_buffer() makes a call to dv_get_version(), so only one *
  61. *   need be used. After the call, your program can use the in_dv variable   *
  62. *   to test if Desqview is present.  If your program does direct screen     *
  63. *   writes, use the get buffer function.  Then the shadow area DV uses will *
  64. *   be in the variables dv_vid_seg and dv_vid_off.  These can be used with  *
  65. *   straight copying functions.  No timing loops are needed, as DV takes    *
  66. *   care of that. If your program uses only BIOS, DOS or the shadow buffer  *
  67. *   then it will run in a small window in Desqview.  I have modified Windows*
  68. *   BOSS for Desqview, and my BATMEN program now runs in DV with no bleeding*
  69. *                                                                           *
  70. *   The other functions are fairly self explanatory. I use the dv_pause()   *
  71. *   when I am in an inkey loop polling for a key stroke.  This speeds up    *
  72. *   the other programs somewhat. The critical functions would be well used  *
  73. *   when setting things like interupts and signals. Anytime that you do not *
  74. *   want to loose program control.                                          *
  75. *                                                                           *
  76. *   problems: none <grin>, I assume people will tell me. Works for me.      *
  77. *   Desqview version 2.0 has a bug and returns the version in reverse order *
  78. *    this version allows for it.                                            *
  79. *                                                                           *
  80. *   I have only tested this under desqview version 2                        *
  81. *                                                                           *
  82. *---------------------------      Author(s)        -------------------------*
  83. *     Initials ---- Name ---------------------------------                  *
  84. *      DjG          Donald J. Gloistein                                     *
  85. *                                                                           *
  86. *************************************************************************@H*/
  87.  
  88. /*@R************************< Revision History >*****************************
  89. *                                                                           *
  90. *   version -- date -- init ---Notes----------------------                  *
  91. *    1.00    12-14-87  DjG  Modified code from DV v2.00 manual              *
  92. *    1.01    01-16-88  DjG  Fixed bug in interface. My fault.               *
  93. *    1.02    01-20-88  DjG  Adjusted for DV 2.0                             *
  94. *                                                                           *
  95. *************************************************************************@R*/
  96. ~ end_of_comments
  97.  
  98. TRUE    EQU     1
  99. FALSE   EQU     0
  100.  
  101. if1
  102. ifdef SMALL
  103. LDATA   EQU     FALSE
  104. LCODE   EQU     FALSE
  105. %out    Small model defined
  106. endif
  107. ifdef MEDIUM
  108. LDATA   EQU     FALSE
  109. LCODE   EQU     TRUE
  110. %out Medium model defined
  111. endif
  112. ifdef LARGE
  113. LDATA   EQU     TRUE
  114. LCODE   EQU     TRUE
  115. %out Large model defined
  116. endif
  117. ifdef COMPACT
  118. LDATA   EQU     TRUE
  119. LCODE   EQU     FALSE
  120. %out Compact model defined
  121. endif
  122.  
  123. ifndef LDATA
  124. LDATA   EQU     FALSE
  125. LCODE   EQU     FALSE
  126. %out  code not defined assuming small model
  127. endif
  128. if  LDATA
  129. %out    LARGE DATA
  130. else
  131. %out    SMALL DATA
  132. endif
  133. if  LCODE
  134. %out    LARGE CODE
  135. else
  136. %out    SMALL CODE
  137. endif
  138. endif
  139.  
  140. if LCODE
  141. CHECKDV_TEXT   SEGMENT  WORD PUBLIC 'CODE'
  142. CHECKDV_TEXT   ENDS
  143. else
  144. _TEXT   SEGMENT  WORD PUBLIC 'CODE'
  145. _TEXT   ENDS
  146. endif
  147.  
  148. CONST   SEGMENT  WORD PUBLIC 'CONST'
  149. CONST   ENDS
  150. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  151. _BSS    ENDS
  152. _DATA   SEGMENT  WORD PUBLIC 'DATA'
  153. _DATA   ENDS
  154.  
  155. if LCODE
  156. DGROUP  GROUP   CONST,  _BSS,   _DATA
  157.         ASSUME  CS: CHECKDV_TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  158. else
  159. DGROUP  GROUP   CONST,  _BSS,   _DATA
  160.         ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  161. endif
  162.  
  163. if LCODE
  164. extrn  __chkstk:far
  165. else
  166. extrn  __chkstk:near
  167. endif
  168.  
  169. _DATA   segment
  170.         public _dv_vid_seg
  171.         public _dv_vid_off
  172.         public _in_dv
  173.         public _dv_maj_version
  174.         public _dv_min_version
  175.  
  176. _dv_vid_seg dw 0
  177. _dv_vid_off dw 0
  178. _in_dv      dw 0
  179. _dv_maj_version dw  0
  180. _dv_min_version dw  0
  181. _DATA   ends
  182.  
  183. if      LCODE
  184. @AB     EQU     6
  185. else
  186. @AB     EQU     4
  187. endif
  188.  
  189. ARG1    EQU     @AB
  190. ARG2    EQU     @AB+2
  191. ARG3    EQU     @AB+4
  192. ARG4    EQU     @AB+6
  193. ARG5    EQU     @AB+8
  194. ARG6    EQU     @AB+10
  195.  
  196. if LCODE
  197. CHECKDV_TEXT   segment
  198. else
  199. _TEXT segment
  200. endif
  201.  
  202.     public  _dv_get_version
  203.     public  _dv_get_video_buffer
  204.     public  _dv_pause
  205.     public  _dv_begin_critical
  206.     public  _dv_end_critical
  207.  
  208. comment ~
  209. /*@F*************************< dv_get_version>*******************************
  210. *                                                                           *
  211. *                      checks for Desqview and version                      *
  212. *                      ---------------------------------                    *
  213. *                                                                           *
  214. *   Checks for presence of desqview. Sets the major and minor version       *
  215. *   global variables. Sets in_dv variable to true if present                *
  216. *                                                                           *
  217. *   Parameters:                                                             *
  218. *       no parameters                                                       *
  219. *       ...             ...                                                 *
  220. *                                                                           *
  221. *   Returns:                                                                *
  222. *       major version number is returned in AX                              *
  223. *       False (0) is returned if not desqview                               *
  224. *************************************************************************@F*/
  225. ~ end_of_comments
  226.  
  227.  
  228. if      LCODE
  229. _dv_get_version    proc    far
  230. else
  231. _dv_get_version    proc    near
  232. endif
  233.         push    bp
  234.         mov     bp,sp
  235.         push    bx
  236.         push    cx
  237.         push    dx
  238.         mov     cx,'DE'      ;set cx and dx to invalid date
  239.         mov     dx,'SQ'
  240.         mov     ax,2b01h     ;dos set date function
  241.         int     21h
  242.         cmp     al,0ffh      ; did dos set date as invalid?
  243.         je      no_desqview   ; if so, desqview isn't there
  244.         mov     ax,bx        ; AH=major version AL = minor version
  245.         mov     _in_dv,1     ;
  246.         cmp     ax,0002h     ; corrects for bug, version 2.0 reverses the
  247.         jne     not_20       ; documented version order.  Comment out
  248.         xchg    al,ah        ; these three lines if it doesnt matter to you.
  249. not_20:
  250.         mov     byte ptr _dv_maj_version,ah  ; not needed, but I want it
  251.         mov     byte ptr _dv_min_version,al
  252.         xchg    al,ah        ; get major version in al
  253.         cbw                  ; set up for return
  254.         jmp     short dvgv_x
  255. no_desqview:
  256.         xor     ax,ax        ;return false (no desqview)
  257. dvgv_x: pop     dx
  258.         pop     cx
  259.         pop     bx
  260.         pop     bp
  261.         ret
  262. _dv_get_version  endp
  263.  
  264. comment ~
  265. /*@F*************************< dv_get_video_buffer >*************************
  266. *                                                                           *
  267. *                      finds the video buffer DV is using                   *
  268. *                      ---------------------------------                    *
  269. *                                                                           *
  270. *   Finds the buffer for direct video screen writing                        *
  271. *                                                                           *
  272. *   unsigned int dv_get_video_buffer(segment)                               *
  273. *   Parameters:                                                             *
  274. *       segment         unsigned int                                        *
  275. *                                                                           *
  276. *   Returns:                                                                *
  277. *       the passed segment if no desqview, new segment if DV is there       *
  278. *       returned value is an unsigned integer.                              *
  279. *       sets up the dv_vid_seg and dv_vid_off to new segments               *
  280. *       otherwise sets them to the current segment with 0 offset            *
  281. *                                                                           *
  282. *************************************************************************@F*/
  283. ~ end_of_comments
  284.  
  285.  
  286. if      LCODE
  287. _dv_get_video_buffer   proc    far
  288. else
  289. _dv_get_video_buffer   proc    near
  290. endif
  291.         push    bp
  292.         mov     bp,sp
  293.         push    di
  294.         push    si         ; lets make sure
  295.         push    es
  296.         mov     es,[bp][ARG1]
  297.         call    _dv_get_version
  298.         test    ax,ax      ; in DV?
  299.         jz      dvgvb_x
  300.         ;since DV is running, get the alternate buffer
  301.         mov     ah,0feh     ; DV's get buffer function
  302.         int     10h         ; returns es:di as alternate buffer
  303.         mov     _dv_vid_off,di
  304. dvgvb_x:
  305.         mov     ax,es       ;return the video segment
  306.         mov     _dv_vid_seg,ax  ; set up the global
  307.         pop     es
  308.         pop     si
  309.         pop     di
  310.         mov     sp,bp
  311.         pop     bp
  312.         ret
  313. _dv_get_video_buffer  endp
  314.  
  315.  
  316. comment ~
  317. /*@F*************************< api_call      >*******************************
  318. *                                                                           *
  319. *                      invokes a desqview interface func                    *
  320. *                      ---------------------------------                    *
  321. *                                                                           *
  322. *   local procedure to invoke desqview API after switching to a stack that  *
  323. *   Desqview provides for the programmer                                    *
  324. *                                                                           *
  325. *   Parameters:                                                             *
  326. *       local procedure, does not follow C calling convention.              *
  327. *       AX contains the function to be invoked                              *
  328. *                                                                           *
  329. *   Returns:                                                                *
  330. *       none                                                                *
  331. *                                                                           *
  332. *************************************************************************@F*/
  333. ~ end_of_comments
  334.  
  335.  
  336. api_call      proc    near
  337.         mov     ax,101ah      ; the func to switch to DV's stack
  338.         int     15H           ; DV's software interupt
  339.         mov     ax,bx         ; move the desired fuction to ax
  340.         int     15H
  341.         mov     ax,1025h      ; the func to swith off of DV's stack
  342.         int     15H
  343.         ret
  344. api_call  endp
  345.  
  346. comment ~
  347. /*@F*************************< dv_pause      >*******************************
  348. *                                                                           *
  349. *                      gives up programs time slice                         *
  350. *                      ---------------------------------                    *
  351. *                                                                           *
  352. *   When the calling program is just polling the key board waiting for      *
  353. *   something to happen, it can use up a lot of time. This releases the     *
  354. *   rest of the time, like if you are using an inkey type loop              *
  355. *                                                                           *
  356. *     void dv_pause(void);                                                  *
  357. *                                                                           *
  358. *   Parameters:  none                                                       *
  359. *                                                                           *
  360. *   Returns:     nothing                                                    *
  361. *                                                                           *
  362. *************************************************************************@F*/
  363. ~ end_of_comments
  364.  
  365.  
  366. if      LCODE
  367. _dv_pause      proc    far
  368. else
  369. _dv_pause      proc    near
  370. endif
  371.         cmp     byte ptr _in_dv,1      ; are we in desqview ?
  372.         jne     dvp_x
  373.         mov     bx,1000h              ; put function code in ax
  374.         call    api_call
  375. dvp_x:  ret
  376. _dv_pause  endp
  377.  
  378.  
  379. comment ~
  380. /*@F*************************< dv_begin_critical >***************************
  381. *                                                                           *
  382. *                      keeps time slice in desqview                         *
  383. *                      ---------------------------------                    *
  384. *                                                                           *
  385. *   This function tells Desqview not to give up your time slice.            *
  386. *   This is used for parts of your program that are critical and you do not *
  387. *   want interupted.                                                        *
  388. *                                                                           *
  389. *      void dv_begin_critical(void)                                         *
  390. *   Parameters:     none                                                    *
  391. *                                                                           *
  392. *   Returns:        nothing                                                 *
  393. *                                                                           *
  394. *************************************************************************@F*/
  395. ~ end_of_comments
  396.  
  397.  
  398. if      LCODE
  399. _dv_begin_critical    proc    far
  400. else
  401. _dv_begin_critical   proc    near
  402. endif
  403.         cmp     byte ptr _in_dv,1
  404.         jne     dvbc_x
  405.         mov     bx,101bH     ; make the begin critical call
  406.         call    api_call
  407. dvbc_x: ret
  408. _dv_begin_critical  endp
  409.  
  410.  
  411. comment ~
  412. /*@F*************************< dv_end_critical >*****************************
  413. *                                                                           *
  414. *                      ends the critical time slice                         *
  415. *                      ---------------------------------                    *
  416. *                                                                           *
  417. *   This function tells Desqview to end the critical time slice.            *
  418. *                                                                           *
  419. *      void dv_end_critical(void)                                           *
  420. *   Parameters:     none                                                    *
  421. *                                                                           *
  422. *   Returns:        nothing                                                 *
  423. *                                                                           *
  424. *************************************************************************@F*/
  425. ~ end_of_comments
  426.  
  427.  
  428. if      LCODE
  429. _dv_end_critical    proc    far
  430. else
  431. _dv_end_critical   proc    near
  432. endif
  433.         cmp     byte ptr _in_dv,1
  434.         jne     dvec_x
  435.         mov     bx,101cH     ; make the begin critical call
  436.         call    api_call
  437. dvec_x: ret
  438. _dv_end_critical  endp
  439.  
  440. if LCODE
  441. CHECKDV_TEXT   ends
  442. else
  443. _TEXT   ends
  444. endif
  445.    end
  446.